/// @tags: Sqrt
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>

namespace BlueQuantum {

int const N = 5e5 + 5, siz = 708;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

int n, m, blocks, ans;
int L[siz + 5], R[siz + 5], max[siz + 5][siz + 5], id[N], tot[N], a[N], hash[N], index[N];
std::vector<int> vec[N];

inline void init() {
  blocks = (n - 1) / siz + 1;
  for (int i = 1; i <= blocks; ++i) L[i] = R[i - 1] + 1, R[i] = i * siz;
  R[blocks] = n;
  for (int i = 1; i <= blocks; ++i) {
    memset(tot, 0, sizeof(tot));
    for (int j = L[i]; j <= R[i]; ++j) id[j] = i;
    for (int j = i; j <= blocks; ++j) {
      int &F = max[i][j];
      F = max[i][j - 1];
      for (int k = L[j]; k <= R[j]; ++k) F = std::max(F, ++tot[a[k]]);
    }
  }
}

inline int main() {
  read(n), read(m);
  for (int i = 1; i <= n; ++i) hash[i] = read(a[i]);
  std::sort(hash + 1, hash + n + 1);
  *hash = std::unique(hash + 1, hash + n + 1) - hash - 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = std::lower_bound(hash + 1, hash + *hash + 1, a[i]) - hash;
    index[i] = vec[a[i]].size();
    vec[a[i]].push_back(i);
  }
  init();
  memset(tot, 0, sizeof(tot));
  for (int l, r; m; --m) {
    read(l) ^= ans, read(r) ^= ans;
    ans = 0;
    if (id[l] != id[r]) {
      ans = max[id[l] + 1][id[r] - 1];
      for (int i = l; i <= R[id[l]]; ++i) {
        int ind = index[i];
        while (ind + ans < static_cast<int>(vec[a[i]].size()) && vec[a[i]][ind + ans] <= r) ++ans;
      }
      for (int i = L[id[r]]; i <= r; ++i) {
        int ind = index[i];
        while (ind - ans >= 0 && vec[a[i]][ind - ans] >= l) ++ans;
      }
    } else {
      for (int i = l; i <= r; ++i) ans = std::max(ans, ++tot[a[i]]);
      for (int i = l; i <= r; ++i) tot[a[i]] = 0;
    }
    printf("%d\n", ans);
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P5048 [Ynoi2019 模拟赛] Yuno loves sqrt technology III.in", "r", stdin);
  freopen("P5048 [Ynoi2019 模拟赛] Yuno loves sqrt technology III.out", "w", stdout);
#endif
#endif

  return BlueQuantum::main();
}